#Check to ensure SharePoint is loaded
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null){
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$stateService = New-SPStateServiceApplication -Name "State Service"
New-SPStateServiceDatabase -Name "StateServiceDatabase" -ServiceApplication $stateService
New-SPStateServiceApplicationProxy -Name "State Service" -ServiceApplication $stateService -DefaultProxyGroup
